﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using InternetClient2.Models;
using System.Net.Http;
using Newtonsoft.Json;
using System.Net.Http.Headers;

namespace InternetClient2.Controllers
{
    public class CargoController : Controller
    {
        // GET: Cargo
        public ActionResult Index()
        {
            return View();
        }
        public void cargoclass()
        {
            Uri uri = new Uri("http://localhost:52745/");
            HttpClient client = new HttpClient();
            client.BaseAddress = uri;
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("Application/json"));


            HttpResponseMessage message = client.GetAsync("/Manager/GetCargo").Result;

            int i = 0;
            if (message.IsSuccessStatusCode)
            {
                var q = message.Content.ReadAsStringAsync().Result;
                string linq = JsonConvert.SerializeObject(q);


                //访问root.response;
                List<Users> list = JsonConvert.DeserializeObject<List<Users>>(q);
                SelectList list2 = new SelectList(list, "LID", "Lname");
            }
        }
        /// <summary>
        /// 货物存储页面
        /// </summary>
        /// <returns></returns>
        public ActionResult Cargocun()
        {
             cargoclass();
            return View();
        }
        [HttpPost]
        public ActionResult Cargocun(Cargo news)
        {
            return View();
        }
    }
}